<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>添加运营中心</title>
    <link rel="stylesheet" type="text/css" href="/static/css/animate.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/public.css"/>
    <script src="/static/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/js/mui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/js/index.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/layer/mobile/layer.js" type="text/javascript" charset="utf-8"></script>
</head>
<body style="background: #fff;">
	<div class="header">
		<a href="/index/" class="backPage"></a>
		<p class="page_title">添加运营中心</p>
	</div>
	<div style="width: 100%; height: 0.88rem; background: none;"></div>
	<div class="inputBox">
		<div class="inputBox_form">
			<p>姓名</p>
			<input type="text" name="realname" placeholder="请输入姓名"/>
		</div>
		<div class="inputBox_form">
			<p>手机号</p>
			<input type="text" name="phone" placeholder="请输入手机号"/>
		</div>
		<div class="inputBox_form">
			<p>密码</p>
			<input type="password" name="pwd" placeholder="请输入密码"/>
		</div>
		<div class="inputBox_form">
			<p>确认密码</p>
			<input type="password" name="repwd" placeholder="请确认密码"/>
		</div>
	</div>
	<div class="login_btn">提交</div>
</body>
<script type="text/javascript">
	function checkMobile(tel) {
		var reg = /(^1[3|4|5|6|7|8|9][0-9]{9}$)/;
		if (reg.test(tel)) {
			return true;
		}else{
			return false;
		};
	}
    $('.login_btn').click(function() {
        var realname=$("input[name='realname']").val();
        var phone=$("input[name='phone']").val();
        var pwd=$("input[name='pwd']").val();
        var repwd=$("input[name='repwd']").val();
        if(realname == ''){
            layer.open({
                content: '请输入真实姓名'
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
            return false;
        }
        if(phone == ''){
            layer.open({
                content: '请输入手机号'
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
            return false;
        }
        if (!checkMobile(phone)) {
			layer.open({
				content: '手机号格式不正确'
				,skin: 'msg'
				,time: 2 //2秒后自动关闭
			});
			return false;
		}
        if(pwd == ''){
            layer.open({
                content: '请输入密码'
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
            return false;
        }
        if(repwd == ''){
            layer.open({
                content: '请确认密码'
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
            return false;
        }
        if(repwd != pwd){
            layer.open({
                content: '两次输入的密码不一致'
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
            return false;
        }
        $.ajax({
            type : "POST",
            url:"/yy_add/",//+tab,
            headers:{"X-CSRFToken":$.cookie('csrftoken')},
            data:{'realname':realname,'phone':phone,'pwd':pwd}, 
            dataType:'json',		
            success: function(data){
               if(data.code == 1){
                    layer.open({
                        content: data.msg
                        ,skin: 'msg'
                        ,time: 3 //2秒后自动关闭
                    });
                    setTimeout(function(){
                        window.location.href="/yy_list/"
                    },700);
                }else{
                    layer.open({
                        content: data.msg
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                }	
            }
        });
    });
</script>
</html>